package cn.studyjava.mybatis.vo;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

import cn.studyjava.common.validator.Add;
import cn.studyjava.common.validator.Mod;

public class LoginUserVO {

	@NotEmpty(message = "{user.name.notempty}", groups = { Add.class })
    @Length(min = 3, max = 64, message = "{user.name.length.error}", groups = { Add.class, Mod.class })
	private String userName;
	
	@NotEmpty(message = "{user.password.notempty}", groups = { Add.class })
    @Length(min = 6, max = 12, message = "{user.password.length.error}", groups = { Add.class, Mod.class })
	private String password;
	
	private String verifyCode;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getVerifyCode() {
		return verifyCode;
	}

	public void setVerifyCode(String verifyCode) {
		this.verifyCode = verifyCode;
	}

	@Override
	public String toString() {
		return "LoginUserVO [userName=" + userName + ", password=" + password + ", verifyCode=" + verifyCode + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((password == null) ? 0 : password.hashCode());
		result = prime * result + ((userName == null) ? 0 : userName.hashCode());
		result = prime * result + ((verifyCode == null) ? 0 : verifyCode.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		LoginUserVO other = (LoginUserVO) obj;
		if (password == null) {
			if (other.password != null) {
				return false;
			}
		} else if (!password.equals(other.password)) {
			return false;
		}
		if (userName == null) {
			if (other.userName != null) {
				return false;
			}
		} else if (!userName.equals(other.userName)) {
			return false;
		}
		if (verifyCode == null) {
			if (other.verifyCode != null) {
				return false;
			}
		} else if (!verifyCode.equals(other.verifyCode)) {
			return false;
		}
		return true;
	}
	
}
